package logic

import (
	"context"
	"go.uber.org/zap"
	"homepage_srv/homepage"
	"homepage_srv/internal/dao"
	"homepage_srv/internal/svc"
	"smart-health-platforms/pkg"
	"strconv"

	"github.com/zeromicro/go-zero/core/logx"
)

type AddReplyLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewAddReplyLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddReplyLogic {
	return &AddReplyLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 添加回复评论
func (l *AddReplyLogic) AddReply(in *homepage.AddReplyRequest) (*homepage.AddReplyResponse, error) {
	reply, err := dao.AddReply(in)
	if err != nil {
		pkg.Error("评论回复失败", zap.Error(err))
		return nil, err
	}
	return &homepage.AddReplyResponse{
		Code:    200,
		Msg:     "评论回复成功",
		ReplyId: strconv.FormatInt(reply.ID, 10),
	}, nil
}
